﻿public class Solution {
    public bool IsAnagram(string s, string t)
    {
        int[] records = new int[26];
        int index = 0;

        foreach (char c in s)
        {
            index = c - 'a';
            records[index]++;
        }
        foreach (char c in t)
        {
            index = c - 'a';
            records[index]--;
        }

        foreach (int num in records)
        {
            if (num != 0)
            {
                return false;
            }
        }
        return true;
    }

    public static void Main(string[] args)
    {
        string s = "anagram";
        string t = "nagaram";

        Solution solution = new Solution();
        bool result = solution.IsAnagram(s, t);
        Console.WriteLine(result);
    }
}